import axios from 'axios'

function ajax_get(path,params){
    return new Promise(function(resolve,reject){
        axios.get(path,{
            params
        }).then(result=>{
            resolve(result.data)
        })
    })
}
import $ from "./jquery.js"
var qs=require('qs')
function ajax_post(path,params){
    console.log(params)
    return new Promise(function(resolve,reject){
        //  axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
        $.post(path, qs.stringify(params)).then(result => {
            resolve(result);
        })
        
    })
}
//注册
function ajax_register(params){
    return ajax_get("/myE/register",params);
}
//登录
function ajax_login(params){
    return ajax_get("/myE/login",params)
}
//更新商铺
function ajax_addShop(params){
    // return ajax_get('/myE/addShop',params)
    return ajax_post('/myE/addShop',params)
}

//添加食品
function ajax_addFood(params){
    return ajax_post('/myE/addFood',params)
}
//商铺信息
function ajax_shopList(params){
    return ajax_post("/myE/shopList",params)
}

//管理员列表
function ajax_admin(params){
    return ajax_get("/myE/admin",params)
}

//食品列表
function ajax_foodList(params){
    return ajax_get("/myE/foodList",params)
}

//修改用户头像
function ajax_userImg(params){
    return ajax_post("/myE/addUserImg",params)
}
//更新商铺信息
function ajax_updateShop(params){
    return ajax_post("/myE/updateShop",params)
}
//更新食品信息
function ajax_updateFood(params){
    return ajax_post("/myE/updateFood",params)
}
//删除食品
function ajax_deleteFood(params){
    return ajax_post("/myE/deleteFood",params)
}
//获得订单列表
function ajax_dDList(params){
    return ajax_get("/myE/dDList",params);
}
//用户列表
function ajax_userList(params){
    return ajax_get('/myE/userList',params)
}
//获取各个数量
function ajax_houTai(params){
    return ajax_get('/myE/houTai',params)
}
//订单配送
function ajax_updateDing(params){
    return ajax_post("/myE/updateDing",params)
}
//获取评价
function ajax_getPing(params){
    return ajax_get("/myE/getPingJia",params)
}
export{
    ajax_register,
    ajax_login,
    ajax_addShop,
    ajax_shopList,
    ajax_admin,
    ajax_addFood,
    ajax_foodList,
    ajax_userImg,
    ajax_updateShop,
    ajax_updateFood,
    ajax_deleteFood,
    ajax_dDList,
    ajax_userList,
    ajax_houTai,
    ajax_updateDing,
    ajax_getPing,
}